﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace Tetris
{
    class TcpReceiver
    {

        public delegate void ListenTCP(Game game);
        public static void listenTcp()
        {
            
            TcpListener server = new TcpListener(IPAddress.Any, 50000);
            server.Start();
            TcpClient client = server.AcceptTcpClient();
            NetworkStream stream = client.GetStream();
            BinaryFormatter formatter = new BinaryFormatter();
            while (true)
            {
                //Tetris.gameMulti =(Game)formatter.Deserialize(stream);
                Game game = (Game)formatter.Deserialize(stream);
                //System.Windows.Forms.Invoke((ListenTCP)Tetris.UpdateGameMulti, game);
            }
        }
    }
}
